home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / NANOTECH.ZIP / 3D.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-28  |  3.7 KB  |  127 lines

  1. /*
  2.  
  3. NanoTech - a 3d game engine
  4. Copyright (C) 1996  Sean Lane Fuller
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. Sean Lane Fuller
  21. 124 Autumn Lane
  22. Tullahoma, TN 37388
  23. 615-393-4550
  24. email: fuller@edge.net
  25.  
  26. */
  27.  
  28. typedef float fixed;
  29. extern char area_type;
  30. typedef unsigned char angle;
  31. float get_obj_radius(int i);
  32. float get_obj_midy(int i);
  33. unsigned char get_obj_type(int i);
  34. int get_obj_id(int i);
  35. void init_3d();
  36. void term_3d();
  37. struct obj_struct *add_obj(int id, unsigned char type);
  38. int del_obj(int id);
  39. int upd_obj(int id, angle yaw, angle pitch, angle roll,
  40.       fixed tx, fixed ty, fixed tz);
  41. int time_slice();
  42. int mark_obj(int id);
  43. int unmark_obj(int id);
  44. int locate_obj(int x, int y);
  45. int is_obj_marked(int id);
  46. int rotate_obj(int id, int dyaw, int dpitch, int droll);
  47. int translate_obj(int id, fixed dx, fixed dy, fixed dz);
  48. int scale_obj(int id, fixed dx, fixed dy, fixed dz);
  49. void  make_scene();
  50. void  draw_scene();
  51. void  pyramid(fixed P[][5], int c);
  52. void  cube(fixed P[][5], int c);
  53. void  wall(fixed P[][5], int c);
  54. void  tran3(fixed tx, fixed ty, fixed tz, fixed A[][5]);
  55. void  scale3(fixed sx, fixed sy, fixed sz, fixed A[][5]);
  56. void  rot3(int m, fixed theta, fixed A[][5]);
  57. void  mult3(fixed A[][5], fixed B[][5], fixed C[][5]);
  58. void  scale3(fixed sx, fixed sy, fixed sz, fixed A[][5]);
  59. void clear_scene();
  60. void  clipscene();
  61. int save_area_by_name(char *filename);
  62. int save_area(int l);
  63. //int load_area(char *filename);
  64. int load_area(int l);
  65. struct vector3 { fixed x, y, z; };
  66. #define maxv 3000
  67. #define maxf 1600
  68. #define maxlist 4000
  69. #define max(a, b) ((a) > (b) ? (a) : (b))
  70. #define min(a, b) ((a) < (b) ? (a) : (b))
  71. #define horiz 256
  72. #define vert 125
  73. #define maxpoly 20
  74. extern fixed epsilon;
  75. extern int firstfree, nov, ntv, nof, ntf; /* counts */
  76. extern struct vector3 act[maxv], obs[maxv], setup[maxv]; /* actual, observed, setup */
  77. extern struct vector3 pro[maxv];
  78. extern int facfront[maxf], size[maxf];
  79. extern int colour[maxf];
  80. extern int nfac[maxf];
  81. extern int faclist[maxlist];
  82. extern struct vector3 direct, eye, zero;
  83. extern fixed Q[5][5];
  84. extern fixed ppd;
  85.  
  86. extern fixed mx, my, mz;
  87. extern fixed yaw, pitch, roll;
  88. extern fixed sin_yaw, cos_yaw, sin_pitch, cos_pitch, sin_roll, cos_roll;
  89.  
  90. extern char wire_frame;
  91. extern int num_objs;
  92. extern int collision_detection;
  93. int collision(fixed x, fixed y, fixed z, fixed delta, int id);
  94.  
  95. #define ON 1
  96. #define OFF 0
  97. #define MAXVAR 3
  98. struct obj_struct
  99. {
  100.    int id;
  101.    unsigned char type;
  102.    unsigned char clipped;
  103.    unsigned char off;
  104.    long state;
  105.    int var[MAXVAR];
  106.    int first_fac;
  107.    int nof;
  108.    int first_vert;
  109.    int nov;
  110.    int first_list;
  111.    int nol;
  112.    angle yaw;
  113.    angle roll;
  114.    angle pitch;
  115.    fixed x, y, z;
  116.    struct vector3 *act;
  117.    unsigned char marked;
  118.    fixed radius;
  119.    fixed midx, midy, midz;  // transformed centroid
  120.    fixed obsx, obsy, obsz;  // observed position of centroid
  121.    fixed actx, acty, actz;  // untransformed centroid
  122. };
  123. extern struct obj_struct **obj;
  124. struct obj_struct *find_obj(int i);
  125. extern float psin[256];
  126. extern float pcos[256];
  127.